//package com.baizhi.controller;
//
//
//import com.baizhi.util.ValidationCodeUtils;
//import org.patchca.service.Captcha;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//
//import javax.imageio.ImageIO;
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.awt.image.BufferedImage;
//import java.io.IOException;
//import java.io.OutputStream;
//
//@Controller
//public class ValidateCode extends HttpServlet {
//    @Override
//    @RequestMapping("validateCode")
//    protected void service(HttpServletRequest req, HttpServletResponse resp)
//            throws ServletException, IOException {
//        //生成动态验证码
//        Captcha captcha = ValidationCodeUtils.getCaptcha();
//        //将验证码中的内容保存到Session作用域中
//        String value = captcha.getChallenge();
//        HttpSession session = req.getSession();
//        session.setAttribute("validateCode", value);
//        //将验证码图片传输到client
//        BufferedImage image = captcha.getImage();
//        OutputStream out = resp.getOutputStream();
//        //使用输出流out，将png格式的image图片传输到client
//        ImageIO.write(image, "png", out);
//    }
//
//}
